home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Extras / Networking / SANA-II / standard.txt < prev    next >
Encoding:
Text File  |  1998-06-06  |  39.1 KB  |  839 lines

  1.  
  2.  
  3.  
  4.      SANA-II Network Device Driver Specification - Rev 2.0 14-Feb-94
  5.  
  6.      (C) Copyright 1992-1998 Amiga, Inc. All Rights Reserved
  7.  
  8.      Amiga Networking Group -  Randell Jesup, Kenneth Dyke
  9.  
  10.      Warning
  11.  
  12.      The information contained herein is subject to change without
  13.      notice. Amiga specifically does not make any endorsement or
  14.      representation with respect to the use, results, or performance of
  15.      the information (including without limitation its capabilities,
  16.      appropriateness, reliability, currentness or availability).
  17.  
  18.      Disclaimer
  19.  
  20.      This information is provided ``As Is'' without warranty of any
  21.      kind, either express or implied.  The entire risk as to the use of
  22.      this information is assumed by the user.  In no event will
  23.      Amiga or its affiliated companies be liable for any damages,
  24.      direct, indirect, incidental, special or consequential, resulting
  25.      from any claim arising out of the information presented herein,
  26.      even if it has been advised of the possibility of such damages.
  27.      Some states do not allow the exclusion or limitation of such
  28.      implied warranties, so the above limitations may not apply.
  29.  
  30.  
  31.      SANA-II Network Device Driver Specification
  32.  
  33.      The SANA-II Network Device Driver Specification is a standard for
  34.      an Amiga software interface between networking hardware and network
  35.      protocol stacks (or for software tools such as network monitors).
  36.      A network protocol stack is a layer of software that network
  37.      applications use to address particular processes on remote machines
  38.      and to send data reliably in spite of hardware errors. There are
  39.      several common network protocol stacks including TCP/IP, OSI,
  40.      AppleTalk, DECNet and Novell.
  41.  
  42.      SANA-II device drivers are intended to allow multiple network
  43.      protocol stacks running on the same machine to share one network
  44.      device. For example, the TCP/IP and AppleTalk protocol stacks could
  45.      both run on the same machine over one ethernet board. The device
  46.      drivers are also intended to allow network protocol stacks to be
  47.      written in a hardware-independent fashion so that a different
  48.      version of each protocol stack doesn't have to be written for each
  49.      networking hardware device.
  50.  
  51.      The standard does not address the writing of network applications.
  52.      Application writers must not use SANA-II Device Drivers directly.
  53.      Network applications must use the API provided by the network
  54.      protocol software the application supports. There is not an Amiga
  55.      standard network API at the time of this writing, though there is
  56.      the AS225 TCP/IP package and its socket.library as well as other
  57.      (third-party) packages.
  58.  
  59.      To write a SANA-II device driver, you will need to be familiar with
  60.      the specification documents for the hardware you are writing to and
  61.      with the SANA-II Network Device Driver Specification.
  62.  
  63.  
  64.  
  65.  
  66.      To write a network protocol stack which will use SANA-II device
  67.      drivers, you should have general familiarity with common network
  68.      hardware and must be very familiar with the SANA-II Network Device
  69.      Driver Specification as well as the specification for the protocol
  70.      you are developing. If you are creating a new protocol, you must
  71.      obtain a protocol type number for any hardware on which your
  72.      protocol will be used.
  73.  
  74.      Commodore supports the SANA-II specification by providing drivers
  75.      for the Commodore-Amiga network hardware. We have an A2065.device
  76.      (Ethernet) and intend to produce an A2060.device (ARCNET). We also
  77.      try to examine review copies of third-party SANA-II networking
  78.      hardware and software to try to make sure that they interoperate
  79.      with our products.
  80.  
  81.      This standard has undergone several drafts with long periods for
  82.      comment from developers and the Amiga community at large. These
  83.      drafts include a UseNet release which was also distributed on the
  84.      Fish Disks in June, 1991 (as well as published in the '91 DevCon
  85.      notes), and the November 7 Draft for Final Comment and Approval
  86.      distributed via Bix, ADSP and UseNet. There were also several
  87.      intermediate drafts with more limited distribution.
  88.  
  89.      This version of the specification is final. Any new version of the
  90.      standard (i.e., to add new features) is planned to be backward
  91.      compatible. No SANA-II device driver or software utilizing those
  92.      drivers should be written to any earlier version of the
  93.      specification.
  94.  
  95.      Distribution of this version of the standard is unlimited. Anyone
  96.      may write Amiga software which implements a SANA-II network device
  97.      driver or which calls a SANA-II network device driver without
  98.      restriction and may freely distribute such software that they have
  99.      written. Amiga is a registered trademark of Amiga, Inc.
  100.      Ethernet is a trademark of Xerox Corporation. ARCNET is a trademark
  101.      of Datapoint Corporation. DECNet is a trademark of Digital
  102.      Equipment Corporation. AppleTalk is a trademark of Apple Computer,
  103.      Inc.
  104.  
  105.      It is important to try to test each SANA-II device driver against
  106.      all software which uses SANA-II devices. Available example programs
  107.      are valuable in initial testing. The Amiga Networking Group is
  108.      interested in receiving evaluation and/or beta test copies of all
  109.      Amiga networking hardware, SANA-II device drivers and software which
  110.      uses SANA-II devices. However, we make no assurances regarding any
  111.      testing which we may or may not perform with such evaluation copies.
  112.      Contact:
  113.  
  114.          Amiga Networking Group
  115.          Commodore International Services Corporation
  116.          Technology Group
  117.          1200 Wilson Drive
  118.          West Chester, PA 19380, USA
  119.  
  120.  
  121.  
  122.  
  123.      Driver Form
  124.  
  125.      SANA-II device drivers are Amiga Exec device drivers. They use an
  126.      extended IORequest structure and a number of extended commands for
  127.      tallying network statistics, sending broadcasts and multicasts,
  128.      network addressing and the handling of unexpected packets. The
  129.      Amiga ROM Kernel Reference Manual: Devices includes information on
  130.      how to construct an Exec device.
  131.  
  132.      Opening a SANA-II Device
  133.  
  134.      As when opening any other Exec device, on the call to OpenDevice() a
  135.      SANA-II device receives an IORequest structure which the device
  136.      initializes for the opener's use. The opener must copy this
  137.      structure if it desires to use multiple asynchronous requests. The
  138.      SANA-II IORequest is defined as follows:
  139.  
  140.      struct IOSana2Req
  141.      {
  142.          struct IORequest ios2_Req;
  143.          ULONG ios2_WireError;
  144.          ULONG ios2_PacketType;
  145.          UBYTE ios2_SrcAddr[SANA2_MAX_ADDR_BYTES];
  146.          UBYTE ios2_DstAddr[SANA2_MAX_ADDR_BYTES];
  147.          ULONG ios2_DataLength;
  148.          APTR *ios2_Data;
  149.          APTR *ios2_StatData;
  150.          APTR *ios2_BufferManagement;
  151.      };
  152.  
  153.        ios2_Req              - A standard Exec device IORequest.
  154.        ios2_WireError        - A more specific device code which may be
  155.                                set when there is an io_Error. See
  156.                                <devices/sana2.h> for the defined
  157.                                WireErrors.
  158.        ios2_PacketType       - The type of packet requested. See the
  159.                                section on ``Packet Types''.
  160.        ios2_SrcAddr          - The device fills in this field with the
  161.                                interface (network hardware) address of
  162.                                the source of the packet that satisfied
  163.                                a read command. The bytes used to hold
  164.                                the address will be left justified but
  165.                                the bit layout is dependent on the
  166.                                particular type of network.
  167.        ios2_DstAddr          - Before the device user sends a packet, it
  168.                                fills this with the interface destination
  169.                                address of the packet. On receives, the
  170.                                device fills this with the interface
  171.                                destination address. Other commands may
  172.                                use this field differently (see the SANA-II
  173.                                Network Device Driver Autodocs). The
  174.                                bytes used to hold the address will be
  175.                                left justified but the bit layout is
  176.                                dependent on the particular type of network.
  177.  
  178.  
  179.  
  180.  
  181.        ios2_DataLength       - The device user initializes this field with
  182.                                the amount of data available in the Data
  183.                                buffer before passing the IOSana2Req to
  184.                                the device. The device fills in this field
  185.                                with the size of the packet data as it was
  186.                                sent on the wire. This does not include
  187.                                the header and trailer information.
  188.                                Depending on the network type and protocol
  189.                                type, the driver may have to calculate
  190.                                this value. This is generally used only
  191.                                for reads and writes (including broadcast
  192.                                and multicast).
  193.        ios2_Data             - A pointer to some abstract data structure
  194.                                containing packet data. Drivers may not
  195.                                directly manipulate or examine anything
  196.                                pointed to by Data! This is generally
  197.                                used only for reads and writes (including
  198.                                broadcast and multicast).
  199.        ios2_StatData         - Pointer to a structure in which to place
  200.                                a snapshot of device statistics. The data
  201.                                area must be long word aligned. This is
  202.                                only used on calls to the statistics
  203.                                commands.
  204.        ios2_BufferManagement - The opener places a pointer to a tag list
  205.                                in this field before calling OpenDevice().
  206.                                Functions pointed to in the tag list are
  207.                                called by the device when processing
  208.                                IORequests from the opener. When returned
  209.                                from OpenDevice(), this field contains a
  210.                                pointer to driver-private information
  211.                                used to access these functions.
  212.                                See ``Buffer Management'' below for more
  213.                                details.
  214.  
  215.      The flags used with the device on OpenDevice() are (SANA2OPB_xxx):
  216.  
  217.        SANA2OPB_MINE  - Exclusive access to the unit requested.
  218.        SANA2OPB_PROM  - Promiscuous mode requested. Hardware which
  219.                         supports promiscuous mode allows all packets
  220.                         sent over the wire to be captured whether or not
  221.                         they are addressed to this node.
  222.  
  223.             Note: Promiscuous mode requres exclusive opening
  224.                   of the device.
  225.  
  226.      The flags used during I/O requests are (SANA2IOB_xxx):
  227.  
  228.        SANA2IOB_RAW   - Raw packet read/write requested. Raw packets
  229.                         should include the entire data-link layer packet.
  230.                         Devices with the same hardware device number
  231.                         should have the same raw packet format.
  232.        SANA2IOB_BCAST - Broadcast packet (received).
  233.        SANA2IOB_MCAST - Multicast packet (received).
  234.        SANA2IOB_QUICK - Quick IO requested.
  235.  
  236.  
  237.  
  238.  
  239.      Buffer Management
  240.  
  241.      Unlike most other Exec Device drivers, SANA-II drivers have no
  242.      internal buffers. Instead, they read/write to/from an abstract data
  243.      structure allocated by the driver user. The driver accesses these
  244.      buffers only via functions that the driver user provides to the
  245.      driver. The driver user must provide two functions--one copies data
  246.      to the abstract data structure and one copies data from the abstract
  247.      data structure. The driver user can therefore choose the data
  248.      structure used for buffer management by both the driver and driver
  249.      user in order to have efficient memory and CPU usage overall.
  250.  
  251.      The IOSana2Req contains a pointer to data and the length of said
  252.      data. A driver is not allowed to make assumptions about how the data
  253.      is stored. The driver cannot directly manipulate or examine the
  254.      buffer in any manner. The driver can only access the buffer by
  255.      calling the functions provided by the driver user.
  256.  
  257.      Before calling OpenDevice(), the driver user points
  258.      ios2_BufferManagement to a list of tags (defined in
  259.      <devices/sana2.h>) which include pointers to the buffer management
  260.      functions required by the driver (defined below).  The driver will
  261.      fail to open if the driver user does not supply all of the required
  262.      functions.  If the device opens successfully, the driver sets
  263.      ios2_BufferManagement to a value which this opener must use in all
  264.      future calls to the driver.  This ``magic cookie'' is used from
  265.      then on to access these functions (a ``magic cookie'' is a value
  266.      which one software entity passes to another but which is only
  267.      meaningful to one of the software entities).  The driver user may
  268.      not use the ``magic cookie'' in any way--it is for the driver to do
  269.      with as it wishes.  The driver could in theory choose to just copy
  270.      the tag list to driver-owned memory and then parse the list for
  271.      every IORequest, but it is much more efficient for the driver to
  272.      create some sort of table of functions and to point
  273.      ios2_BufferManagement to that table.
  274.  
  275. ****New
  276.  
  277.      Another recommendation for the ``magic cookie`` is to use it to
  278.      maintain a seperate packet read queue for each device opener.  This
  279.      would allow multiple protocol stacks that all wish to receive the
  280.      same packet type to work together without having to "know" about
  281.      each other as Envoy and AS225 do right now.
  282.  
  283.      The C= SLIP and A2065 driver now do this, so it would be possible
  284.      (for example) to run Envoy, AS225 and the AmiTCP package together
  285.      on the same hardware without conflicts.
  286.  
  287.      In order to help system load, a new callback has been added to allow
  288.      protocol stacks to reject packets that are known to not be useful.
  289.      Envoy's nipc.library (for example) could be modified to reject TCP
  290.      packets (as it never uses them).
  291.  
  292. ****New
  293.  
  294.      The specification currently defines three Tags for the
  295.      OpenDevice() ios2_BufferManagement tag list:
  296.  
  297.      S2_CopyToBuff  - This is a pointer to a function which conforms to
  298.               the CopyToBuff Autodoc.
  299.      S2_CopyFromBuff - This is a pointer to a function which conforms to
  300.               the CopyFromBuff Autodoc.
  301.      S2_PacketFilter [optional] - This is a pointer to a standard Hook
  302.                to be called before S2_CopyToBuff is done.  See the
  303.                PacketFilter Autodoc for more information.
  304.  
  305.      Packet Type
  306.  
  307.      Network frames always have a type field associated with them. These
  308.      type fields vary in length, position and meaning by frame type
  309.      (frame types generally correspond one-to-one with hardware types,
  310.      but see ``Ethernet Packet Types'' below). The meanings of the type
  311.      numbers are always carefully defined and every type number is
  312.      registered with some official body. Do not use a type number which
  313.      is not registered for any standard hardware you use or in a manner
  314.      inconsistent with that registration.
  315.  
  316.      The type field allows the SANA-II device driver to fulfill CMD_READs
  317.      based on the type of packet the driver user wants. Multiple
  318.      protocols can therefore run over the same wire using the same driver
  319.      without stepping on each other's toes.
  320.  
  321.  
  322.  
  323.  
  324.      Packet types are specified as a long word. Unfortunately, the type
  325.      field means different things on different wires. Driver users must
  326.      allow their software to be configured with a SANA-II device name,
  327.      unit number and the type number(s) used by the protocol stack with
  328.      each device. This way, if new hardware becomes available, a
  329.      hardware manufacturer can supply a listing of type assignments to
  330.      configure pre-existing software.
  331.  
  332.      Ethernet Packet Types
  333.  
  334.      Ethernet has a special problem with packet types. Two types of
  335.      ethernet frames can be sent over the same wire--ethernet and 802.3.
  336.      These frames differ in that the Type field of an ethernet frame is
  337.      the Length field of an 802.3 frame. This creates a problem in that
  338.      demultiplexing incoming packets can be cumbersome and inefficient,
  339.      as well as requiring driver users to be aware of the frame type
  340.      used.
  341.  
  342.      All 802.3 frames have numbers less than 1500 in the Type field. The
  343.      only frames with numbers less than 1500 in the type field are 802.3
  344.      frames. SANA-II ethernet drivers abnormally return packets
  345.      contained in ethernet frames when the requested Type falls within
  346.      the 802.3 range--if the Type requested is within the 802.3 range,
  347.      the driver returns the next packet contained within an 802.3 frame,
  348.      regardless of the type specified for the packet within the 802.3
  349.      frame. This requires that there be no more than one driver user
  350.      requesting 802.3 packets and that it do its own interpretation of
  351.      the frames.
  352.  
  353.      ARCNET Frames
  354.  
  355.      ARCNET also has a special problem with framing. ARCNET frames
  356.      consist of a hardware header and a software header. The software
  357.      header is in the data area of the hardware packet, and includes at
  358.      least the protocol ID.
  359.  
  360.      There are two types of software header. Old-style ARCNET software
  361.      headers consist entirely of a one or two byte protocol ID. New
  362.      ARCNET software headers (defined in RFC 1201 and in the paper
  363.      ``ARCNET Packet Header Definition Standard'', Novell, Inc., 1989)
  364.      include more information. They allow more efficient use of ARCNET
  365.      through data link layer fragmentation and reassembly (ARCNET has a
  366.      small Maximum Transmission Unit) and allow sending any size packet up
  367.      to the MTU (rather than requiring that packets of size 253, 254 and
  368.      255 be padded to at least 256 bytes).
  369.  
  370.      SANA-II device drivers for ARCNET should implement the old ARCNET
  371.      packet headers. Driver users which wish to interoperate with
  372.      platforms using the new software headers must add the new fields to
  373.      the data to be sent and must process it for incoming data. A
  374.      SANA-II driver which implemented the data link layer fragmentation
  375.      internally (and advertised a large MTU) could be more efficient than
  376.      requiring the driver user to do it. This would make driver writing
  377.      more difficult and reduce interoperability, but if there is ever a
  378.      demand for that extra performance, a new hardware type may be
  379.      assigned by Commodore for SANA-II ARCNET device drivers which
  380.      implement the new framing.
  381.  
  382.  
  383.  
  384.  
  385.      Addressing
  386.  
  387.      In the SANA-II standard, network hardware addresses are stored in an
  388.      array of n bytes. No meaning is ascribed by the standard to the
  389.      contents of the array.
  390.  
  391.      In case there exists a network which does not have an address field
  392.      consisting of a number of bits not divisible by eight, add pad bits
  393.      at the end of the bit stream. For example, if an address is ten
  394.      bits long it will be stored like this:
  395.  
  396.          98765432 10PPPPPP
  397.          BYTE 0   BYTE 1
  398.  
  399.      Where the numerals are bit numbers and 'P' is a pad (ignored) bit.
  400.  
  401.      Driver users which do not implement the bit shifting necessary to
  402.      use a network with such addressing (if one exists) should at least
  403.      check the number of significant bits in the address field (returned
  404.      from the device's S2_DEVICEQUERY function) to make sure that it is
  405.      evenly divisible by eight.
  406.  
  407.      Driver users will map hardware addresses to protocol addresses in a
  408.      protocol and hardware dependent manner, as described by the relevant
  409.      standards (i.e., RFC 826 for TCP/IP over Ethernet, RFC 1201 or 1051
  410.      for TCP/IP over ARCNET). Some protocols will always use the same
  411.      mapping on all hardware, but other protocols will have particular
  412.      address mapping schemes for some particular hardware and a
  413.      reasonable default for other (unknown) hardware.
  414.  
  415.      Some SANA-II devices will have ``hardware addresses'' which aren't
  416.      really hardware addresses. As an example, consider PPP
  417.      (Point-to-Point Protocol). PPP is a standard for transmitting IP
  418.      packets over a serial line. It uses IP addresses negotiated during
  419.      the establishment of a connection. In a SANA-II driver
  420.      implementation of PPP, the driver would negotiate the address at
  421.      S2_CONFIGINTERFACE. Thus, the address in SrcAddr returned by the
  422.      device on an S2_CONFIGINTERFACE (or in a subsequent
  423.      S2_GETSTATIONADDRESS) will be a protocol address, not a true
  424.      hardware address.
  425.  
  426.      Note: Some hardware always uses a ROM hardware address. Other
  427.      hardware which has a ROM address or is configurable with DIP
  428.      switches may be overridden by software. Some hardware always
  429.      dynamically allocates a new hardware address at initialization. See
  430.      ``Configuration'' for details on how this is handled by driver
  431.      writers and by driver users.
  432.  
  433.      Hardware Type
  434.  
  435.      The HardwareType returned by the device's S2_DEVICEQUERY function is
  436.      necessary for those protocols whose standards require different
  437.      behavior on different hardware. It is also useful for determining
  438.      appropriate packet type numbers to use with the device. The
  439.      HardwareType values already issued for standard network hardware are
  440.      the same as those in RFC 1060 (assigned numbers). Hardware
  441.      developers implementing networks without a SANA-II hardware number
  442.      must contact CATS to have a new hardware type number assigned.
  443.      Driver users should all have reasonable defaults which can be used
  444.      for hardware with which they are not familiar.
  445.  
  446.  
  447.  
  448.  
  449.      Errors
  450.  
  451.      The SANA-II extended IORequest structure (struct IOSana2Req)
  452.      includes both the ios2_Error and ios2_WireError fields. Driver
  453.      users must always check IOSana2Reqs on return for an error in
  454.      ios2_Error. ios2_Error will be zero if no error occurred, otherwise
  455.      it will contain a value from <exec/errors.h> or <devices/sana2.h>.
  456.      If there was an error, there may be more specific information in
  457.      ios2_WireError. Drivers are required to fill in the WireError if
  458.      there is an applicable error code.
  459.  
  460.      Error codes are #defined in the ``defined errors'' sections of
  461.      the file <devices/sana2.h>:
  462.  
  463.      IOSana2Req S2io_Error field (S2ERR_xxx):
  464.  
  465.      S2ERR_NO_RESOURCES  - Insufficient resources available.
  466.      S2ERR_BAD_ARGUMENT  - Noticeably bad argument.
  467.      S2ERR_BAD_STATE     - Command inappropriate for current state.
  468.      S2ERR_BAD_ADDRESS   - Noticeably bad address.
  469.      S2ERR_MTU_EXCEEDED  - Write data too large.
  470.      S2ERR_NOT_SUPPORTED - Command is not supported by this driver. This
  471.                            is similar to IOERR_NOCMD as defined in
  472.                            <exec/errors.h> but S2ERR_NOT_SUPPORTED
  473.                            indicates that the requested command is a
  474.                            valid SANA-II command and that the driver
  475.                            does not support it because the hardware is
  476.                            incapable of supporting it (e.g.,
  477.                            S2_MULTICAST). Note that IOERR_NOCMD is still
  478.                            valid for reasons other than a lack of
  479.                            hardware support (i.e., commands which are
  480.                            no-ops in a SANA-II driver).
  481.      S2ERR_SOFTWARE      - Software error of some kind.
  482.      S2ERR_OUTOFSERVICE  - When a hardware device is taken off-line, any
  483.                            pending requests are returned with this error.
  484.  
  485.      See also the standard errors in <exec/errors.h>.
  486.  
  487.      IOSana2Req S2io_WireError field (S2WERR_xxx):
  488.  
  489.      S2WERR_NOT_CONFIGURED  - Command requires unit to be configured.
  490.      S2WERR_UNIT_ONLINE     - Command requires that the unit be off-line.
  491.      S2WERR_UNIT_OFFLINE    - Command requires that the unit be on-line.
  492.      S2WERR_ALREADY_TRACKED - Protocol is already being tracked.
  493.      S2WERR_NOT_TRACKED     - Protocol is not being tracked.
  494.      S2WERR_BUFF_ERROR      - Buffer management function returned an error.
  495.      S2WERR_SRC_ADDRESS     - Problem with the source address field.
  496.      S2WERR_DST_ADDRESS     - Problem with destination address field.
  497.      S2WERR_BAD_BROADCAST   - Problem with an attempt to broadcast.
  498.      S2WERR_BAD_MULTICAST   - Problem with an attempt to multicast.
  499.      S2WERR_MULTICAST_FULL  - Multicast address list full.
  500.      S2WERR_BAD_EVENT       - Event specified is unknown.
  501.      S2WERR_BAD_STATDATA    - The S2IO_StatData pointer or the data it
  502.                               points to failed a sanity check.
  503.      S2WERR_IS_CONFIGURED   - Attempt to reconfigure the unit.
  504.      S2WERR_NULL_POINTER    - A NULL pointer was detected in one of the
  505.                               arguments. S2ERR_BAD_ARGUMENT should always
  506.                               be the S2ERR.
  507.  
  508.  
  509.  
  510.  
  511.      Standard Commands
  512.  
  513.      See the SANA-II Network Device Driver Autodocs for full details on
  514.      each of the SANA-II device commands. Extended commands are
  515.      explained in the sections below.
  516.  
  517.      Many of the Exec device standard commands are no-ops in SANA-II
  518.      devices, but this may not always be the case. For example,
  519.      CMD_RESET might someday be used for dynamically reconfiguring
  520.      hardware. This should present no compatibility problems for
  521.      properly written drivers.
  522.  
  523.      Broadcast and Multicast
  524.  
  525.        S2_ADDMULTICASTADDRESS        S2_MULTICAST
  526.        S2_DELMULTICASTADDRESS        S2_BROADCAST
  527.  
  528.      Some hardware supports broadcast and/or multicast. A broadcast is a
  529.      packet sent to all other machines. A multicast is a packet sent to a
  530.      set of machines. Drivers for hardware which does not allow broadcast
  531.      or multicast will return ios2_Error S2ERR_NOT_SUPPORTED as
  532.      appropriate.
  533.  
  534.      To send a broadcast, use S2_BROADCAST instead of CMD_WRITE.
  535.      Broadcasts are received just like any other packets (using a
  536.      CMD_READ for the appropriate packet type).
  537.  
  538.      To send a multicast, use S2_MULTICAST instead of CMD_WRITE. The
  539.      device keeps a list of addresses that want to receive multicasts.
  540.      You add a receiver's address to this list by using
  541.      S2_ADDMULTICASTADDRESS. The receiver then posts a CMD_READ for the
  542.      type of packet to be received. Some SANA-II devices which support
  543.      multicast may have a limit on the number of addresses that can
  544.      simultaneously wait for packets. Always check for an
  545.      S2WERR_MULTICAST_FULL error return when adding a multicast address.
  546.  
  547.      Note that when the device adds a multicast address, it is usually
  548.      added for all users of the device, not just the driver user which
  549.      called S2_ADDMULTICASTADDRESS. In other words, received multicast
  550.      packets will fill a read request of the appropriate type regardless
  551.      of whether the requesting driver user is the same one which added
  552.      the multicast address.
  553.  
  554.      In general, driver users should not care how received packets were
  555.      sent (normally or broadcast/multicast), only that it was received.
  556.      If a driver user really must know, however, it can check for
  557.      SANA2IOB_BCAST and/or SANA2IOB_MCAST in the ios2_Flags field.
  558.  
  559.      Drivers should keep a count for the number of opens on a multicast
  560.      address so that they don't actually remove it until it has been
  561.      S2_DELMULTICASTADDRESS'd as many times as it has been
  562.      S2_ADDMULTICASTADDRESS'd.
  563.  
  564.  
  565.  
  566.  
  567.      Stats
  568.  
  569.        S2_TRACKTYPE     S2_GETTYPESTATS      S2_GETGLOBALSTATS
  570.        S2_UNTRACKTYPE   S2_GETSPECIALSTATS   S2_READORPHAN
  571.  
  572.      There are many statistics which may be very important to someone
  573.      trying to debug, tune or optimize a protocol stack, as well as to
  574.      the end user who may need to tune parameters or investigate a
  575.      problem. Some of these statistics can only be kept by the SANA-II
  576.      driver, thus there are several required and optional statistics and
  577.      commands for this purpose.
  578.  
  579.      S2_TRACKTYPE tells the device driver to gather statistics for a
  580.      particular packet type. S2_UNTRACKTYPE tells it to stop (keeping
  581.      statistics by type causes the driver to use additional resources).
  582.      S2_GETTYPESTATS returns any statistics accumulated by the driver for
  583.      a type being tracked (stats are lost when a type is
  584.      S2_UNTRACKTYPE'd). Drivers are required to implement the
  585.      functionality of type tracking. The stats are returned in a struct
  586.      Sana2PacketTypeStats:
  587.  
  588.      struct Sana2PacketTypeStats
  589.      {
  590.        ULONG PacketsSent;
  591.        ULONG PacketsReceived;
  592.        ULONG BytesSent;
  593.        ULONG BytesReceived;
  594.        ULONG PacketsDropped;
  595.      };
  596.  
  597.      PacketsSent     - Number of packets of a particular type sent.
  598.      PacketsReceived - Number of packets of a particular type that
  599.                        satisfied a read command.
  600.      BytesSent       - Number of bytes of data sent in packets of a
  601.                        particular type.
  602.      BytesReceived   - Number of bytes of data of a particular packet
  603.                        type that satisfied a read command.
  604.      PacketsDropped  - Number of packets of a particular type that were
  605.                        received while there were no pending reads of that
  606.                        packet type.
  607.  
  608.      S2_GETGLOBALSTATS returns global statistics kept by the driver.
  609.      Drivers are required to keep all applicable statistics. Since all
  610.      are applicable to most hardware, most drivers will maintain all
  611.      statistics. The stats are returned in a struct Sana2DeviceStats:
  612.  
  613.      struct Sana2DeviceStats
  614.      {
  615.        ULONG PacketsReceived;
  616.        ULONG PacketsSent;
  617.        ULONG BadData;
  618.        ULONG Overruns;
  619.        ULONG UnknownTypesReceived;
  620.        ULONG Reconfigurations;
  621.        struct timeval LastStart;
  622.      };
  623.  
  624.  
  625.  
  626.  
  627.      PacketsReceived     - Number of packets that this unit has received.
  628.      PacketsSent         - Number of packets that this unit has sent.
  629.      BadData             - Number of bad packets received (i.e., hardware
  630.                            CRC failed).
  631.      Overruns            - Number of packets dropped due to insufficient
  632.                            resources available in the network interface.
  633.      UnknownTypeReceived - Number of packets received that had no pending
  634.                            read command with the appropriate packet type.
  635.      Reconfigurations    - Number of network reconfigurations since this
  636.                            unit was last configured.
  637.      LastStart           - The time when this unit last went on-line.
  638.  
  639.      S2_GETSPECIALSTATS returns any special statistics kept by a
  640.      particular driver. Each new wire type will have a set of
  641.      documented, required statistics for that wire type and a standard
  642.      set of optional statistics for that wire type (optional because they
  643.      might not be available from all hardware). The data returned by
  644.      S2_GETSPECIALSTATS will require wire-specific interpretation. See
  645.      <devices/sana2specialstats.h> for currently defined special
  646.      statistics. The statistics are returned in the following
  647.      structures:
  648.  
  649.      struct Sana2SpecialStatRecord
  650.      {
  651.        ULONG Type;
  652.        ULONG Count;
  653.        char *String;
  654.      };
  655.  
  656.      Type   - Statistic identifier.
  657.      Count  - Statistic itself.
  658.      String - An identifying, null-terminated string for the statistic.
  659.               Should be plain ASCII with no formatting characters.
  660.  
  661.      struct Sana2SpecialStatHeader
  662.      {
  663.        ULONG RecordCountMax;
  664.        ULONG RecordCountSupplied;
  665.        struct Sana2SpecialStatRecord[RecordCountMax];
  666.      };
  667.  
  668.      RecordCountMax      - There is space for this many records into which
  669.                            statistics may be placed.
  670.      RecordCountSupplied - Number of statistic records supplied.
  671.  
  672.      S2_READORPHAN is not, strictly speaking, a statistical function. It
  673.      is a request to read any packet of a type for which there is no
  674.      outstanding CMD_READ. S2_READORPHAN might be used in the same
  675.      manner as many statistics, though, such as to determine what packet
  676.      types are causing overruns, etc.
  677.  
  678.  
  679.  
  680.  
  681.      Configuration
  682.  
  683.        S2_DEVICEQUERY     S2_CONFIGINTERFACE    S2_GETSTATIONADDRESS
  684.  
  685.      The device driver needs to configure the hardware before using it.
  686.      The driver user must know some network hardware parameters (hardware
  687.      address and MTU, for example) when using it. These commands address
  688.      those needs.
  689.  
  690.      When a driver user is initialized, it should try to
  691.      S2_CONFIGINTERFACE even though an interface can only be configured
  692.      once and someone else may have done it. Before you call
  693.      S2_CONFIGINTERFACE, first call S2_GETSTATIONADDRESS to determine the
  694.      factory address (if any). Also provide for user-override of the
  695.      factory address (that address may be optional and the user may need
  696.      to override it). When S2_CONFIGINTERFACE returns, check the
  697.      ios2_SrcAddr for the actual address the hardware has been configured
  698.      with. This is because some hardware (or serial line standards such
  699.      as PPP) always dynamically allocates an address at initialization.
  700.  
  701.      Driver users will want to use S2_DEVICEQUERY to determine the MTU
  702.      and other characteristics of the network. The structure returned
  703.      from S2_DEVICEQUERY is defined as:
  704.  
  705.      struct Sana2DeviceQuery
  706.      {
  707.        ULONG SizeAvailable;
  708.        ULONG SizeSupplied;
  709.        ULONG DevQueryFormat;
  710.        ULONG DeviceLevel;
  711.        UWORD AddrFieldSize;
  712.        ULONG MTU;
  713.        ULONG BPS;
  714.        ULONG HardwareType;
  715.      };
  716.  
  717.      SizeAvailable  - Size, in bytes, of the space available in which to
  718.                       place device information. This includes both size
  719.                       fields.
  720.      SizeSupplied   - Size, in bytes, of the data supplied.
  721.      DevQueryFormat - The format defined here is format 0.
  722.      DeviceLevel    - This spec defines level 0.
  723.      AddrFieldSize  - The number of bits in an interface address.
  724.      MTU            - Maximum Transmission Unit, the size, in bytes,
  725.                       of the maximum packet size, not including header
  726.                       and trailer information.
  727.      BPS            - Best guess at the raw line rate for this network
  728.                       in bits per second.
  729.      HardwareType   - Specifies the type of network hardware the driver
  730.                       controls.
  731.  
  732.  
  733.  
  734.  
  735.  
  736.      On-line
  737.  
  738.           S2_ONLINE       S2_ONEVENT       S2_OFFLINE
  739.  
  740.      In order to run hardware tests on an otherwise live system, the
  741.      S2_OFFLINE command allows the SANA-II device driver to be ``turned
  742.      off'' until the tests are complete and an ONLINE is sent to the
  743.      driver. S2_ONLINE causes the interface to re-configure and
  744.      re-initialize. Any packets destined for the hardware while the
  745.      device is off-line will be lost. All pending and new requests to the
  746.      driver shall be returned with S2ERR_OUTOFSERVICE when a device is
  747.      off-line.
  748.  
  749.      All driver users must understand that any IO request may return with
  750.      S2ERR_OUTOFSERVICE because the driver is off-line (any other program
  751.      may call S2_OFFLINE to make it so). In such an event, the driver
  752.      will usually want to wait until the unit comes back on-line (for the
  753.      program which called S2_OFFLINE to call S2_ONLINE). It may do this
  754.      by calling S2_ONEVENT to wait for S2EVENT_ONLINE. S2_ONEVENT allows
  755.      the driver user to wait on various events.
  756.  
  757.      A driver must track events, but may not distinguish between some
  758.      types of events. Drivers return S2_ONEVENT with S2_ERR_NOT
  759.      SUPPORTED and S2WERR_BAD_EVENT for unsupported Events. One error
  760.      may cause more than one Event (see below). Errors which seem to
  761.      have been caused by a malformed or unusual request should not
  762.      generally trigger an event.
  763.  
  764.      Event types (S2EVENT_xxx):
  765.  
  766.        ERROR    - Return when any error occurs.
  767.        TX       - Return on any transmit error (always an error).
  768.        RX       - Return on any receive error (always an error).
  769.        ONLINE   - Return when unit goes on-line or return immediately if
  770.                   unit is already on-line (not an error).
  771.        OFFLINE  - Return when unit goes off-line or return immediately if
  772.                   unit is already off-line (not an error.)
  773.        BUFF     - Return on any buffer management function error (always
  774.                   an error).
  775.        HARDWARE - Return when any hardware error occurs (always an error,
  776.                   may be a TX or RX, too).
  777.        SOFTWARE - Return when any software error occurs (always an error,
  778.                   may be a TX or RX, too).
  779.  
  780.      Driver Installation
  781.  
  782.      The standard system location for SANA-II network device driver is
  783.      in a directory called "Networks" which exists in the "DEVS:"
  784.      directory.
  785.  
  786.          Example:
  787.  
  788.             DEVS:Networks/a2065.device
  789.  
  790.      This is the official location for the drivers.  It may be necessary
  791.      for your install program/script to create this directory if it doesn't
  792.      exist in a user's system.
  793.  
  794.  
  795.      Acknowledgments
  796.  
  797.      Many people and companies have contributed to the SANA-II Network
  798.      Device Driver Specification. The original SANA-II Autodocs and
  799.      includes were put together by Ray Brand, Perry Kivolowitz (ASDG) and
  800.      Martin Hunt. Those original documents evolved to their current
  801.      state and grew to include this document at the hands of Dale Larson
  802.      and Greg Miller. Brian Jackson and John Orr provided valuable
  803.      editing. Randell Jesup has provided sage advice on several
  804.      occasions. The buffer management callback mechanism was his idea.
  805.      Dale Luck (GfxBase) and Rick Spanbauer (Ameristar Technologies) have
  806.      provided valuable comments throughout the process. Nicolas Benezan
  807.      (ADONIS) provided many detailed and useful comments on weaknesses in
  808.      late drafts of the specification. Thanks to all the above and the
  809.      numerous others who have contributed with their comments, questions
  810.      and discussions.
  811.  
  812.  
  813.  
  814.  
  815.      Unresolved Issues
  816.  
  817.      Unfortunately, it isn't possible to completely isolate network
  818.      protocols from the hardware they run on. Hardware types and
  819.      addressing both remain somewhat hardware-dependent in spite of our
  820.      efforts. See the ``Packet Type'' section for an explanation of how
  821.      packet types are handled and why protocols cannot be isolated from
  822.      them. See the ``Addressing'' section for an explanation of how
  823.      addressing is handled any why protocols cannot be isolated from it.
  824.  
  825.      Additionally, there are at least two cases where a hardware type has
  826.      multiple framing methods in use (ethernet/802.3 and arcnet/(Novell)
  827.      ``ARCNET Packet Header Definition Standard''). In both cases,
  828.      software which must interoperate with other platforms on this
  829.      hardware may need to be aware of the distinctions and may have to do
  830.      extra processing in order to use the appropriate frame type. See
  831.      the sections on ``Ethernet Packet Types'' and on ``ARCNET frames''
  832.      for more details.
  833.  
  834.      Another feature that SANA-II currently lacks is any concept of
  835.      dynamic addressing.  Some hardware types such as LocalTalk or
  836.      dialup SLIP/PPP connections may change their address on the fly.
  837.      Currently there is no way for a device driver to report this event
  838.      back to a protocol stack.
  839.